﻿using System;
using System.Collections.Generic;
using System.Text;
using Lottery.App.Model;
using System.Drawing;

namespace UI
{
    abstract class Graph
    {
        #region Constructors

        public Graph()
        {
            A1 = A2 = A3 = ImageManager.N01;
            N01 = N02 = N03 = N04 = N05 = N06 = N07 = N08 = N09 = N10 = ImageManager.Null;
            N11 = N12 = N13 = N14 = N15 = N16 = N17 = N18 = N19 = N20 = ImageManager.Null;
        }

        #endregion

        #region Properties

        public virtual Image A1 { get; protected set; }

        public virtual Image A2 { get; protected set; }

        public virtual Image A3 { get; protected set; }

        //public RecordInfo Record { get; protected set; }

        public string IssueNum { get; protected set; }

        public virtual Image N01 { get; protected set; }

        public virtual Image N02 { get; protected set; }

        public virtual Image N03 { get; protected set; }

        public virtual Image N04 { get; protected set; }

        public virtual Image N05 { get; protected set; }

        public virtual Image N06 { get; protected set; }

        public virtual Image N07 { get; protected set; }

        public virtual Image N08 { get; protected set; }

        public virtual Image N09 { get; protected set; }

        public virtual Image N10 { get; protected set; }

        public virtual Image N11 { get; protected set; }

        public virtual Image N12 { get; protected set; }

        public virtual Image N13 { get; protected set; }

        public virtual Image N14 { get; protected set; }

        public virtual Image N15 { get; protected set; }

        public virtual Image N16 { get; protected set; }

        public virtual Image N17 { get; protected set; }

        public virtual Image N18 { get; protected set; }

        public virtual Image N19 { get; protected set; }

        public virtual Image N20 { get; protected set; }

        public string Result { get; protected set; }

        #endregion

        #region Protected Methods

        protected void SetImage(string number)
        {
            this.SetImage(Convert.ToInt32(number));
        }

        protected void SetImage(int number)
        {
            switch (number)
            {
                case 1: N01 = ImageManager.N01; break;
                case 2: N02 = ImageManager.N02; break;
                case 3: N03 = ImageManager.N03; break;
                case 4: N04 = ImageManager.N04; break;
                case 5: N05 = ImageManager.N05; break;
                case 6: N06 = ImageManager.N06; break;
                case 7: N07 = ImageManager.N07; break;
                case 8: N08 = ImageManager.N08; break;
                case 9: N09 = ImageManager.N09; break;
                case 10: N10 = ImageManager.N10; break;
                case 11: N11 = ImageManager.N11; break;
                case 12: N12 = ImageManager.N12; break;
                case 13: N13 = ImageManager.N13; break;
                case 14: N14 = ImageManager.N14; break;
                case 15: N15 = ImageManager.N15; break;
                case 16: N16 = ImageManager.N16; break;
                case 17: N17 = ImageManager.N17; break;
                case 18: N18 = ImageManager.N18; break;
                case 19: N19 = ImageManager.N19; break;
                case 20: N20 = ImageManager.N20; break;
                default:
                    break;
            }
        }

        #endregion

    }

    class GraphA1 : Graph
    {
        public GraphA1(RecordInfo record)
        {
            this.IssueNum = record.IssueNum;
            this.Result = record.Result;

            this.SetImage(record.A1);
        }
    }

    class GraphA3 : Graph
    {
        public GraphA3(RecordInfo record)
        {
            this.IssueNum = record.IssueNum;
            this.Result = record.Result;

            foreach (string item in record.A3.Split(' '))
            {
                this.SetImage(item);
            }
        }
    }

    class GraphN8 : Graph
    {
        public GraphN8(RecordInfo record)
        {
            this.IssueNum = record.IssueNum;
            this.Result = record.Result;

            foreach (string item in record.Result.Split(' '))
            {
                this.SetImage(item);
            }

            A1 = ImageManager.GetImage(Convert.ToInt32(record.Result.Substring(0, 2)));
            A2 = ImageManager.GetImage(Convert.ToInt32(record.Result.Substring(3, 2)));
            A3 = ImageManager.GetImage(Convert.ToInt32(record.Result.Substring(6, 2)));
        }
    }
}
